/**
 * 
 */
package com.shine.icis.dto;

import java.text.DecimalFormat;

import com.shine.icis.config.SysCodeDictLoader;

/**
 * 对应A13信息
 * 
 * @author zhangxr
 */
public class RptA13 {

	private DecimalFormat doubleFormat = new DecimalFormat("0.00");
	private RptA13Id id;
	private String arapReason;// 应收付原因
	private double arapAmt;// 应收应付金额
	private String arapDate;// 应收付日期
	private String summary;// 摘要信息
	

	public RptA13Id getId() {
		return id;
	}

	public void setId(RptA13Id id) {
		this.id = id;
	}

	public void setId(String companyCode, String tradeDate, String arapType,
			String oppPar, String mktCodeSipf, String curTypeSipf,
			String arapBusiType, String harapDate, String busiDate) {
		id = new RptA13Id();
		id.setCompanyCode(companyCode);
		id.setTradeDate(tradeDate);
		id.setArapType(arapType);
		id.setOppPar(oppPar);
		id.setMktCodeSipf(mktCodeSipf);
		id.setArapBusiType(arapBusiType);
		id.setCurTypeSipf(curTypeSipf);
		id.setHarapDate(harapDate);
		id.setBusiDate(busiDate);
	}

	public String getArapReason() {
		return arapReason;
	}

	public void setArapReason(String arapReason) {
		this.arapReason = arapReason;
	}

	public double getArapAmt() {
		return arapAmt;
	}

	public String getArapAmtText() {
		return doubleFormat.format(arapAmt);
	}

	public void setArapAmt(double arapAmt) {
		this.arapAmt = arapAmt;
	}


	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getFormatTradeDate() {
		StringBuffer date = new StringBuffer(id.tradeDate);
		date.insert(6, "-").insert(4, "-");
		return date.toString();
	}
	public String getFormatHarapDate() {
		StringBuffer date = new StringBuffer(id.harapDate);
		date.insert(6, "-").insert(4, "-");
		return date.toString();
	}
	public String getFormatArapDate() {
		if (arapDate == null) {
			return "";
		}
		StringBuffer date = new StringBuffer(arapDate);
		date.insert(6, "-").insert(4, "-");
		return date.toString();
	}
	public String getFormatBusiDate() {
		StringBuffer date = new StringBuffer(id.busiDate);
		date.insert(6, "-").insert(4, "-");
		return date.toString();
	}
	public String getArapType(){
		return id.arapType;
	}
	public String getArapTypeText() {
		return id.arapType + ":" + SysCodeDictLoader.getInstance().getArapTypeConfText(id.arapType);
	}
	
	public String getArapReasonText() {
		return arapReason + ":" + SysCodeDictLoader.getInstance().getArapReasonConfText(arapReason);
	}
	
	public String getCurTypeSipfText() {
		return id.curTypeSipf + ":" + SysCodeDictLoader.getInstance().getCurTypeSipfConfText(id.curTypeSipf);
	}
	
	public String getOppParText() {
		String tem = SysCodeDictLoader.getInstance().getOppParConfText(id.oppPar);
		return tem != null ? (id.oppPar+ ":" + tem) : ("TA代码:" + id.oppPar);
	}
	
	public String getMktCodeSipfText() {
		return id.mktCodeSipf + ":" + SysCodeDictLoader.getInstance().getMktCodeSipfConfText(id.mktCodeSipf);
	}
	
	public String getArapBusiTypeText() {
		return id.arapBusiType + ":" + SysCodeDictLoader.getInstance().getArapBusiTypeConfText(id.arapBusiType);
	}
	
	public class RptA13Id {
		private String companyCode;// 证监会确定的证券公司机构编码
		private String tradeDate;// 交易日期
		private String arapType;// 应收应付类型
		private String oppPar;// 对方机构
		private String mktCodeSipf;// 市场代码
		private String curTypeSipf;// 币种类别
		private String arapBusiType;// 业务类型
		private String harapDate;// 已收付日期
		private String busiDate;// 业务日期

		public String getCompanyCode() {
			return companyCode;
		}

		public void setCompanyCode(String companyCode) {
			this.companyCode = companyCode;
		}

		public String getTradeDate() {
			return tradeDate;
		}

		public void setTradeDate(String tradeDate) {
			this.tradeDate = tradeDate;
		}

		public String getArapType() {
			return arapType;
		}

		public void setArapType(String arapType) {
			this.arapType = arapType;
		}

		public String getOppPar() {
			return oppPar;
		}

		public void setOppPar(String oppPar) {
			this.oppPar = oppPar;
		}

		public String getMktCodeSipf() {
			return mktCodeSipf;
		}

		public void setMktCodeSipf(String mktCodeSipf) {
			this.mktCodeSipf = mktCodeSipf;
		}

		public String getCurTypeSipf() {
			return curTypeSipf;
		}

		public void setCurTypeSipf(String curTypeSipf) {
			this.curTypeSipf = curTypeSipf;
		}

		public String getArapBusiType() {
			return arapBusiType;
		}

		public void setArapBusiType(String arapBusiType) {
			this.arapBusiType = arapBusiType;
		}

		public String getHarapDate() {
			return harapDate;
		}

		public void setHarapDate(String harapDate) {
			this.harapDate = harapDate;
		}
		
		public String getBusiDate() {
			return busiDate;
		}

		public void setBusiDate(String busiDate) {
			this.busiDate = busiDate;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result
					+ ((arapBusiType == null) ? 0 : arapBusiType.hashCode());
			result = prime * result
					+ ((arapType == null) ? 0 : arapType.hashCode());
			result = prime * result
					+ ((curTypeSipf == null) ? 0 : curTypeSipf.hashCode());
			result = prime * result
					+ ((mktCodeSipf == null) ? 0 : mktCodeSipf.hashCode());
			result = prime * result
					+ ((oppPar == null) ? 0 : oppPar.hashCode());
			result = prime * result + Integer.parseInt(tradeDate);
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			final RptA13Id other = (RptA13Id) obj;
			if (companyCode != null && companyCode.equals(other.getCompanyCode())
					&&tradeDate != null && tradeDate.equals(other.getTradeDate()) 
					&& arapType != null && arapType.equals(other.getArapType()) 
					&& oppPar != null && oppPar.equals(other.getOppPar()) 
					&& mktCodeSipf != null && mktCodeSipf.equals(other.getMktCodeSipf()) 
					&& arapBusiType != null && arapBusiType.equals(other.getArapBusiType()) 
					&& curTypeSipf != null && curTypeSipf.equals(other.getCurTypeSipf())
					&& harapDate != null && harapDate.equals(other.getHarapDate())) {
				return true;
			}
			return false;
		}

	}

	public String getArapDate() {
		return arapDate;
	}

	public void setArapDate(String arapDate) {
		this.arapDate = arapDate;
	}

}
